﻿using System.Text;

namespace await前后线程Id测试
{
    internal class Program
    {
        static async Task Main(string[] args)
        {
            Console.WriteLine(Thread.CurrentThread.ManagedThreadId);
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < 1; i++)
            {
                sb.Append("Hello");
            }

            await File.WriteAllTextAsync(@"d:\1.txt", sb.ToString());
            Console.WriteLine(Thread.CurrentThread.ManagedThreadId);

            //理论执行结果：如果i比较小，则前后线程Id相同；如果i比较大，则前后线程Id不同
            //我电脑上测试结果：无论i多小，前后线程Id均不同。我电脑性能不行？
        }
    }
}
